package com.luguangtao.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
 * @类名: com.luguangtao.config
 * @作者: lgt
 * @创建时间: 2019-12-13 14:49
 * @描述:
 **/
@Configuration
@EnableSwagger2
public class TestSwaggerConfig {

    @Bean
    public Docket getDocket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .groupName("test1") //分组
                .select()
                .paths(PathSelectors.ant("/test/**"))  //匹配的路径生成接口文档
                .apis(RequestHandlerSelectors.basePackage("com.luguangtao.web"))  //加载那个包下的接口
                .build();
    }

    @Bean
    public ApiInfo getApiInfo() {
        Contact contact=new Contact("张三","http://www.baidu.com","2363585701@qq.com");
        return  new ApiInfoBuilder()
                .contact(contact)
                .description("接口文档的描述信息")
                .title("接口文档的大标题")
                .termsOfServiceUrl("http://www.taobao.com")
                .version("2.0.3")
                .build();
    }


    @Bean
    public Docket getDocket2(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(getApiInfo())
                .groupName("test2")  //分组
                .select()
                .paths(PathSelectors.ant("/nihao/**"))  //匹配的路径生成接口文档
                .apis(RequestHandlerSelectors.basePackage("cn.swagger5.web")) //加载那个包下的接口
                .build();
    }
}
